package com.example.controller;

import com.example.service.ExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/excel")
public class ExcelController {
    @Autowired
    private ExcelService excelService;

    /**
     *
     * @param path
     * @return 字符串提示信息
     */
    @PutMapping("/operate")
    public String operate(@RequestParam("path") String path){
        return excelService.operate(path);
    }

    /**
     *
     * @param path
     * @return 字符串提示信息
     */
    @PutMapping("/handle")
    public String handle(@RequestParam("path") String path){
        return excelService.handleExcel(path);
    }

    /**
     *处理excel中数据错位
     * @param path
     * @return 字符串提示信息
     */
    @PutMapping("/malposition")
    public String malposition(@RequestParam("path") String path){
        return excelService.handleMalposition(path);
    }

    /**
     *补充issn
     * @param originalPath,issnPath
     * @return 字符串提示信息
     */
    @PutMapping("/issn")
    public String issn(String originalPath,String issnPath){
        return excelService.replenishIssn(originalPath,issnPath);
    }

    /**
     *补充issn2
     * @param originalPath,issn2Path
     * @return 字符串提示信息
     */
    @PutMapping("/add/issn2")
    public String addIssn2(String originalPath,String issn2Path){
        return excelService.addIssn2(originalPath,issn2Path);
    }

    /**
     *保留issn
     * @param originalPath,issnPath，issnPath2，issnPath3
     * @return 字符串提示信息
     */
    @PutMapping("/reserve/issn")
    public String reserveIssn(String originalPath, String issnPath, String issnPath2, String issnPath3){
        return excelService.reserveIssn(originalPath,issnPath,issnPath2,issnPath3);
    }

    /**
     *增加价格数据
     * @param originalPath,fieldPath
     * @return 字符串提示信息
     */
    @PutMapping("/add/price")
    public String addPrice(String originalPath,String fieldPath){
        return excelService.addPriceField(originalPath,fieldPath);
    }

    /**
     *增加创刊时间数据
     * @param originalPath,fieldPath
     * @return 字符串提示信息
     */
    @PutMapping("/add/createTime")
    public String addCreateTime(String originalPath,String fieldPath){
        return excelService.addCreateTimeField(originalPath,fieldPath);
    }

    /**
     *增加主办单位数据
     * @param originalPath,fieldPath
     * @return 字符串提示信息
     */
    @PutMapping("/add/organizer")
    public String addOrganizer(String originalPath,String fieldPath){
        return excelService.addOrganizerField(originalPath,fieldPath);
    }

    /**
     *合并杂志期刊数据
     * @param originalPath,targetPath
     * @return 字符串提示信息
     */
    @PutMapping("/merge")
    public String merge(String originalPath, String targetPath){
        return excelService.merge(originalPath,targetPath);
    }

    /**
     *去重杂志期刊数据
     * @param originalPath
     * @return 字符串提示信息
     */
    @PutMapping("/deduplicate")
    public String deduplicate(String originalPath){
        return excelService.deduplicate(originalPath);
    }

    /**
     * 高德抓的数据处理名称
     * @param poiPath
     * @return 字符串提示信息
     */
    @PutMapping("/handleName")
    public String handleName(String poiPath){
        return excelService.handleName(poiPath);
    }
}
